import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// 6.vite构建时生产环境时移除console
// https://vite.dev/config/
// 7.自定义vite插件my-plugin将构建后的代码中所有的console.log替换为console.info

export default defineConfig({
  plugins: [
    react(),
    {
      name: "my-plugin",
      transform(code, id) {
        return code.replace(/console\.log/g, "console.info");
      },
    },
  ],
  

  server: {
    proxy: {
      "/api": {
        target: "http://localhost:3000",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ""),
      },
    },
  },
  resolve: {
    alias: {
      "@": "src",
    },
  },
});
